package hkr.budget;

import org.achartengine.*;
import org.achartengine.chart.AbstractChart;
import org.achartengine.model.CategorySeries;
import org.achartengine.renderer.*;

import com.example.budget.R;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.ViewSwitcher;


public class Graph extends GraphicalView {

	public static int[] colors = new int[] { Color.GREEN,  Color.CYAN, Color.BLUE,
			Color.GRAY, Color.MAGENTA, Color.RED, Color.YELLOW};

	public static String[] catagories = new String[] {"Bills", "Cloths",
		"Entertaintment", "Food", "Hobby", "Transport", "Income"};

	public static double[] data = { 10, 10, 10, 40, 10, 10, 10} ;

	Context context;


	public Graph(Context context, AbstractChart arg1) {
		super(context, arg1);
	}

	public static GraphicalView getPieChart(Context c)	{

		return ChartFactory.getPieChartView(c, getCategorySet(), getPieChartRender());
	}


	private static DefaultRenderer getPieChartRender() {

		DefaultRenderer render  = new DefaultRenderer();

	    for(int i = 0 ;i<data.length;i++){
	        SimpleSeriesRenderer simple_Renderer = new SimpleSeriesRenderer();
	        simple_Renderer.setColor(colors[i]);
	        simple_Renderer.setDisplayChartValues(true);
	        render.addSeriesRenderer(simple_Renderer);
	    }
	    render.setShowLegend(false);
		return render;
	}


	private static CategorySeries getCategorySet() {

		CategorySeries budgetCatagories = new CategorySeries("Budget OverView");

	    for(int i=0 ;i < catagories.length;i++){
	    	budgetCatagories.add(catagories[i], data[i]);
	    }
		return budgetCatagories;
	}




}
